#!/bin/sed -f
# run sed by 'sed -f trap.sed inc/trap.h'
# or './trap.sed inc/trap.h'
# to generage TRAPHANDLER code

# delete comment
/^\//d

# delete non-define lines
/^#define/!d

# remove define
s/#define\s\+//

# remove non-Trap
/^T/!d

# remove comments
s/\/\/.*$//

# finally
s/\(\w\+\)\s\+\(\w\+\)/TRAPHANDLER(vector\2, \1)/


